package com.example.jnuexperiment2025;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class BookDetailsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_details);

        EditText editTextTitle = findViewById(R.id.edit_text_book_title);
        EditText editTextPrice = findViewById(R.id.edit_text_book_price);
        Button buttonSave = findViewById(R.id.button_save);

        Intent intent = getIntent();
        if (intent.hasExtra("title")) {
            editTextTitle.setText(intent.getStringExtra("title"));
        }

        buttonSave.setOnClickListener(v -> {
            Intent replyIntent = new Intent();
            replyIntent.putExtra("title", editTextTitle.getText().toString());
            replyIntent.putExtra("price", editTextPrice.getText().toString());
            setResult(RESULT_OK, replyIntent);
            finish();
        });
    }
}